#ifndef _VULCAN_EQUIP_
#define _VULCAN_EQUIP_

#include "aerial\Game\GameObject\Equipment\Equipment.h"

#include "hge\hge.h"
#include "hge\hgeparticle.h"
#include "hge\hgeresource.h"
#include "Box2D\Box2D.h"

class FlyObject;
class Fighter;

class VulcanRayCastCallback;

class VulcanEquip: public Equipment
{
	enum VulcanEquipState { On, Fade, Off };
public:
	VulcanEquip(b2World* world, Fighter* _host);
	~VulcanEquip();

	void start();
	bool isOn();
	void stop();

	void renderVulcan();
	bool update(float dt);

	void Hit(float fraction);
	bool available();
	
	Fighter* host;
private:
	b2World* world;
	b2Vec2 Ts, Td, D;

	float t_range, max_range;

	hgeSprite	*sprInner, *sprOuter;
	hgeParticleSystem *psInner, *psOuter;

	VulcanEquipState vulcanEquipState;

	/// @brief speed in which Vulcan is shoot out
	static const float Speed;
	/// @brief power required by vulcan
	static const float MinPowerRequire;
	/// @brief callback when hit an object
	VulcanRayCastCallback* VRCC ;

	/// @brief power consumed per seconed
	static const int FadeSpeed;
	static const float MaxRange;

};

class VulcanRayCastCallback: public b2RayCastCallback
{
public:
	VulcanRayCastCallback(VulcanEquip* _vulcanEquip): vulcanEquip(_vulcanEquip)  {	m_fixture = 0;	}
	float32 ReportFixture(b2Fixture *fixture,  const b2Vec2& point,  const b2Vec2& normal, float32 fraction);
private:
	b2Fixture* m_fixture;
	b2Vec2 m_point;
	b2Vec2 m_normal;
	float32 m_fraction;
	VulcanEquip* vulcanEquip;
};

#endif